package main

import (
	"net/http"

	"github.com/gin-gonic/gin"
)

/*
路由分组
*/
func main() {
	r := gin.Default()

	defaultRouters := r.Group("/")
	{
		defaultRouters.GET("/index", func(c *gin.Context) {
			c.String(http.StatusOK, "index page")
		})
		defaultRouters.GET("/hello/:name", func(c *gin.Context) {
			c.String(http.StatusBadRequest, "请求hello失败")
		})
	}

	apiRouters := r.Group("/api")
	{
		apiRouters.GET("/index", func(c *gin.Context) {
			c.String(http.StatusOK, "api index page")
		})
		apiRouters.GET("/hello/:name", func(c *gin.Context) {
			c.String(http.StatusOK, "请求hello失败")
		})
	}

	r.Run(":9000")

}
